import {ref} from 'vue'

export default {
  scrollUp(tableRef) {
    const tb = document.getElementsByClassName('ant-table-body')[0]

    const tableScroll = ref(true)
    tb.addEventListener('mouseover', () => {
      tableScroll.value = false
    })
    tb.addEventListener('mouseout', () => {
      tableScroll.value = true
    })
    // console.log(tb[0].scrollTop)
    // tb[0].scrollTop = 30
    setInterval(() => {
      if (tableScroll.value) {
        tb.scrollTop += 1.2
        if (tb.clientHeight + tb.scrollTop == tb.scrollHeight) {
          tb.scrollTop = 0
        }
      }
    }, 50)
  },
  // 停止滚动
  pauseScroll() {
    // 定时器不为空
    if (this.scrollTimer) {
      // 清除定时器
      clearInterval(this.scrollTimer)
      this.scrollTimer = null
    }
  }
}
